package cn.wolfcode.p2p.controller;

import cn.wolfcode.p2p.business.query.RechargeQueryObject;
import cn.wolfcode.p2p.business.service.IPlatformBankInfoService;
import cn.wolfcode.p2p.business.service.IRechargeOfflineService;
import cn.wolfcode.p2p.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 后台充值审核页面
 */
@Controller
public class RechargeOfflineAuditController {

    @Autowired
    private IRechargeOfflineService offlineService;
    @Autowired
    private IPlatformBankInfoService bankInfoService;


    /**
     * 线下充值审核页面
     * @param qo
     * @param model
     * @return
     */
    @RequestMapping("rechargeOffline")
    public String rechargeOffline(@ModelAttribute("qo") RechargeQueryObject qo, Model model) {

        model.addAttribute("pageInfo", offlineService.selectForPage(qo));
        //查询所有的银行信息
        model.addAttribute("banks", bankInfoService.listAll());

        return "rechargeoffline/list";
    }

    //审核充值申请
    @RequestMapping("rechargeOffline_audit")
    @ResponseBody
    public JsonResult rechargeOffline_audit(Long id, Integer state, String remark) {

        offlineService.auditRecharge(id, state, remark);
        return JsonResult.instance();
    }


}
